/* global window */
import modelExtend from 'dva-model-extend'
import { pathMatchRegexp } from 'utils'
import api from 'api'
import { DataListModel } from 'utils/model'

const {query${api?cap_first}}=api

export default modelExtend(DataListModel, {
  namespace: '${namespace}',

  state: {
    filterItem:{}
  },

  subscriptions: {

  },

  effects: {
    *query({ payload = {} }, { call, put, select }) {
      const data = yield call(query${api?cap_first},payload)
      const {error,result}=data
      if (!error) {
        yield put({
          type: 'querySuccess',
          payload: {
            list: result.rows,
            pagination: {
              current: Number(payload.page) || 1,
              pageSize: Number(payload.pageSize) || 10,
              total: result.total,
            },
          },
        })
      }
    },

  },

  reducers: {

  },
})
